package com.bw.func;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class LaterViewdFuntion  extends TableFunction<Row> {
    public void eval(String str) throws IOException {
        StringReader reader = new StringReader(str);

        IKSegmenter ikSegmenter = new IKSegmenter(reader, true);
        Lexeme next = ikSegmenter.next();

        while (next!=null){
            collect(Row.of(next.getLexemeText()));
            next=ikSegmenter.next();
        }


    }
}
